/*
 * scheduler.h
 *
 *  Created on: Mar 10, 2012
 *      Author: our_beastie
 */

#ifndef SCHEDULER_H_
#define SCHEDULER_H_

#include "queue.h"
#include "process.h"
#include "ArrayList.h"

#define NUM_PRIORITY 3

struct CPUStr;
typedef struct CPUStr* CPU_SCHED;

enum SchedulerType {
    	ROUND_ROBIN,
        PRIORITY,
        LOTTERY
} SchedulerType;

enum Priority {
    	HIGH,
        MEDIUM,
        LOW
} Priority;

typedef struct {
	Queue round_robin_queue;
	Queue priority_queue[NUM_PRIORITY];
	CPU_SCHED cpu;
	Process running;
	enum SchedulerType scheduler_type;
} SchedulerStr;

typedef SchedulerStr* Scheduler;

Scheduler newScheduler(const int max_processes, enum SchedulerType sched_type, CPU_SCHED cpu);

void initializeScheduler(Scheduler s);

Process getRunningProcess(Scheduler s);
Process switchProcess(Scheduler s, int pc);
void addToReadyQueue(Scheduler s, Process p);
Process getFromReadyQueue(Scheduler s);
Process getNextProcess(Scheduler s);


#endif /* SCHEDULER_H_ */
